package appapi.dao;

import appapi.entity.mqtt.Reserve;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @version: java version 1.8
 * @Author: Ygp Work
 * @description:
 * @date: 2023-07-06 13:54
 */
@Mapper
public interface ReserveMapper {
    @Select("SELECT i.* FROM devices d JOIN reserve i ON d.devices_id = i.devices_id WHERE d.devices_id = #{devicesId}")
    Reserve getAllReserves(Long devicesId);

    @Insert("INSERT INTO reserve (reservenumber, reservename, reservetype, reserveheight, reservebuildtype, " +
            "coordinatetype, coordinatenumber, coordinateradius, coordinatex, coordinatey, coordinatestart, " +
            "coordinateend, devices_id) " +
            "VALUES (#{reservenumber}, #{reservename}, #{reservetype}, #{reserveheight}, #{reservebuildtype}, " +
            "#{coordinatetype}, #{coordinatenumber}, #{coordinateradius}, #{coordinatex}, #{coordinatey}, " +
            "#{coordinatestart}, #{coordinateend}, #{devicesId})")
    void addReserve(Reserve reserve);
}
